/**
 * Class with javascript utils.
 */
js = {};
js.loadedModules = {};

/*
 * Function for include javascript files.
 */
js.include = function(path)
{
	if(js.loadedModules[path]) return;

	var transport = js.getXHTTPTransport();
	
  transport.onreadystatechange = function()
  {
    if (transport.readyState == 4) {
      if (transport.status == 200) {
      	var code = transport.responseText;
        eval(code);
      }
    }
  }
	transport.open('GET', js.jsRoot + path.replace(/\./g, '/') + '.js', false);
	transport.send(null);
}

/*
 * Get XHTTP object.
 */
js.getXHTTPTransport = function()
{
  var xmlhttp;
  
  try {
    xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
  } catch (e) {
    try {
      xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    } catch (E) {
      xmlhttp = false;
    }
  }
  if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
    xmlhttp = new XMLHttpRequest();
  }
  return xmlhttp;
}
